package com.example.bijiabao.mapper;

import org.apache.ibatis.annotations.*;
import com.example.bijiabao.entity.collect;
import com.example.bijiabao.entity.collectView;

import java.util.List;

@Mapper
public interface CollectionMapper {
//    //查询所有收藏信息
//    @Select("select * from collect")
//    List<collect> findAllcollect();

    //添加收藏
    @Insert("insert into collect (userId,pfId,bookId,collect_createTime,remark) values(#{userId},#{pfId},#{bookId},SYSDATE(),#{remark})")
    Integer insertcollect(collect collect);

    //删除收藏信息
    @Delete("delete from collect where collectId=#{collectId}")
    Integer DelLikeByID(Integer collectId);

//    //修改收藏信息
//    @Select("select * from collect where collectId=#{collectId}")
//    Like SelectLikeByID(String like_id);
//
//    @Update("update collect set collectId=#{collectId},userId=#{userId},pfId=#{pfId},bookId=#{bookId},collect_createTime=#{collect_createTime},remark=#{remark} where collectId=#{collectId}")
//    Integer updateLikeByID(collect collect);

    //查询用户自己的收藏
    @Select("select collect.*,book.* from collect join book on book.bookId=collect.bookId where userId=#{userId} ORDER BY collectId desc")
    List<collectView> SelectLikeByUserID(Integer userId);
}
